package threadtest;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @author shentianyu
 * @date 2021-06-29 12:22
 */
public class MyCallable implements Callable {
    @Override
    public Object call() throws Exception {
        Thread.sleep(1000);
        System.out.println(Thread.currentThread().getName()+"---");
        return new Object();
    }
}

class CallableDemo{
    public static void main(String[] args) throws Exception {
        FutureTask futureTask = new FutureTask(new MyCallable());
        new Thread(futureTask).start();
        Object o = futureTask.get();
        System.out.println(o);
    }
}
